package com.mvp.lt.example.websocket;

import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;

import java.net.URI;

/**
 * Created by Android Studio.
 * User: Administrator
 * Name: AirLineView
 * functiona:
 * Date: 2019/5/7 0007
 * Time: 上午 10:05
 */
public class SocketClient extends WebSocketClient {

    public SocketClient(URI serverUri) {
        super(serverUri);
    }

    @Override
    public void onOpen(ServerHandshake handshakedata) {
        System.out.println( "加入连接" );
    }

    @Override
    public void onMessage(String message) {
        System.out.println( message);
    }

    @Override
    public void onClose(int code, String reason, boolean remote) {
        System.out.println( "Connection closed by " + ( remote ? "remote peer" : "us" ) );
    }

    @Override
    public void onError(Exception ex) {
        ex.printStackTrace();
    }
}
